const Router = require("koa-router")

const router = new Router({ prefix: "/users" })
const controller = require("../controller/user")

const { auth, checkSelf } = require("../partMiddle/auth")

router.get("/", controller.user.getUsers)

router.post("/", controller.user.addUser)

router.patch("/:uid", auth, checkSelf, controller.user.updateUser)

router.get("/:uid", auth, checkSelf, controller.user.getUserById)

router.delete("/:uid", controller.user.deleteUser)

router.post("/login", controller.user.login)

router.get("/error/412", controller.user.errTest412)

router.get("/error/500", controller.user.errTest500)

router.get("/:uid/followings", controller.user.listFollowings)

router.put("/follow/:uid", auth, controller.user.follow)

router.delete("/follow/:uid", auth, controller.user.cancelFollow)

router.get("/fans/:uid", controller.user.listFans)

module.exports = router
